module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        clean: ['build'],

        copy: {
            lib: {
                expand: true,
                cwd: 'src/',
                src: ['lib/**'],
                dest: 'build/'
            },
            common: {
                expand: true,
                cwd: 'src/',
                src: ['common/**'],
                dest: 'build/'
            },
            base: {
                expand: true,
                cwd: 'src/base/',
                src: ['**'],
                dest: 'build/'
            },
            demo: {
                expand: true,
                cwd: 'src/demo/',
                src: ['**'],
                dest: 'build/'
            },
            app: {
                expand: true,
                cwd: 'src/app/',
                src: ['**'],
                dest: 'build/'
            },
            pay: {
                expand: true,
                cwd: 'src/pay/',
                src: ['**'],
                dest: 'build/'
            },
            wgw: {
                expand: true,
                cwd: 'src/tmplWgw/',
                src: ['**'],
                dest: 'build/'
            },
            wgw2: {
                expand: true,
                cwd: 'src/tmplWgw2/',
                src: ['**'],
                dest: 'build/'
            },
            wxd: {
                expand: true,
                cwd: 'src/tmplWxd/',
                src: ['**'],
                dest: 'build/'
            },
            mall: {
                expand: true,
                cwd: 'src/tmplMall/',
                src: ['**'],
                dest: 'build/'
            },
            test: {
                expand: true,
                cwd: 'src/test/',
                src: ['**'],
                dest: 'build/'
            },
            wxd2: {
                expand: true,
                cwd: 'src/tmplWxd2/',
                src: ['**'],
                dest: 'build/'
            },
            diancan: {
                expand: true,
                cwd: 'src/tmplDianCan/',
                src: ['**'],
                dest: 'build/'
            },
            custom: {
                expand: true,
                cwd: 'src/tmplCustom/',
                src: ['**'],
                dest: 'build/'
            },
            beauty: {
                expand: true,
                cwd: 'src/tmplBeauty/',
                src: ['**'],
                dest: 'build/'
            },
            fanli: {
                expand: true,
                cwd: 'src/wbFanli/',
                src: ['**'],
                dest: 'build/'
            },
            cityinfo: {
                expand: true,
                cwd: 'src/tmplCityInfo/',
                src: ['**'],
                dest: 'build/'
            },
            maoye: {
                expand: true,
                cwd: 'src/tmplMaoYe/',
                src: ['**'],
                dest: 'build/'
            },
            houtai: {
                expand: true,
                cwd: 'src/tmplHouTai/',
                src: ['**'],
                dest: 'build/'
            },
            xiexie: {
                expand: true,
                cwd: 'src/wbXiexie/',
                src: ['**'],
                dest: 'build/'
            }
        },

        watch: {
            beauty: {
                files: ['src/**'],
                tasks: ['beauty'],
                options: {
                    spawn: false,
                },
            },

            mall: {
                files: ['src/**'],
                tasks: ['mall'],
                options: {
                    spawn: false,
                },
            },

            test: {
                files: ['src/**'],
                tasks: ['test'],
                options: {
                    spawn: false,
                },
            },

            diancan: {
                files: ['src/**'],
                tasks: ['diancan'],
                options: {
                    spawn: false,
                },
            },

            custom: {
                files: ['src/**'],
                tasks: ['custom'],
                options: {
                    spawn: false,
                },
            },

            fanli: {
                files: ['src/**'],
                tasks: ['fanli'],
                options: {
                    spawn: false,
                },
            },
            cityinfo: {
                files: ['src/**'],
                tasks: ['cityinfo'],
                options: {
                    spawn: false,
                },
            },
            maoye: {
                files: ['src/**'],
                tasks: ['maoye'],
                options: {
                    spawn: false,
                },
            },
            houtai: {
                files: ['src/**'],
                tasks: ['houtai'],
                options: {
                    spawn: false,
                },
            },
            demo: {
                files: ['src/**'],
                tasks: ['demo'],
                options: {
                    spawn: false,
                },
            },

            xiexie: {
                files: ['src/**'],
                tasks: ['xiexie'],
                options: {
                    spawn: false,
                },
            },
        },

        // uglify: {
        //   options: {
        //     banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
        //   },
        //   build: {
        //     src: 'src/a.js',
        //     dest: 'build/a.min.js'
        //   }
        // }


    });


    // grunt.loadNpmTasks('grunt-contrib-uglify');  
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-watch');


    grunt.registerTask('wgw', ['clean', 'copy:common', 'copy:app', 'copy:wgw']);
    grunt.registerTask('wgw2', ['clean', 'copy:app', 'copy:wgw2']);
    grunt.registerTask('wxd', ['clean', 'copy:lib', 'copy:pay', 'copy:app', 'copy:wxd']);
    grunt.registerTask('wxd2', ['clean', 'copy:app', 'copy:wxd2']);
    grunt.registerTask('mall', ['clean', 'copy:lib', 'copy:common', 'copy:pay', 'copy:app', 'copy:mall']);
    grunt.registerTask('diancan', ['clean', 'copy:lib', 'copy:common', 'copy:pay', 'copy:app', 'copy:diancan']);
    grunt.registerTask('test', ['clean', 'copy:lib', 'copy:common', 'copy:pay', 'copy:app', 'copy:test']);
    grunt.registerTask('custom', ['clean', 'copy:lib', 'copy:pay', 'copy:app', 'copy:mall', 'copy:custom']);
    grunt.registerTask('beauty', ['clean', 'copy:app', 'copy:beauty']);
    grunt.registerTask('fanli', ['clean', 'copy:lib', 'copy:fanli']);
    grunt.registerTask('cityinfo', ['clean', 'copy:lib', 'copy:common', 'copy:pay', 'copy:app', 'copy:cityinfo']);
    grunt.registerTask('maoye', ['clean', 'copy:lib', 'copy:base', 'copy:demo', 'copy:maoye']);
    grunt.registerTask('houtai', ['clean', 'copy:lib', 'copy:common', 'copy:pay', 'copy:app', 'copy:houtai']);

    grunt.registerTask('xiexie', ['clean', 'copy:lib', 'copy:base', 'copy:xiexie']);

};